{
 "metadata": {
  "kernelspec": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "display_name": "IPython (Python 2)",
   "language": "python",
   "name": "python2"
  },
  "name": "",
  "signature": "sha256:979a0162b06d52a558346e5d2dc9fbb78974651d0b18014d1d738da9a542f1d9"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from yt.units import Msun, pc, kpc, Mpc, km, s, Gyr, Kelvin\n",
      "from yt.utilities.physical_constants import mp, G, kb\n",
      "from numpy import sqrt, pi"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "box_size = 1.31072*Mpc \n",
      "n_top_grid = 64\n",
      "maximum_level = 8\n",
      "dx = box_size / n_top_grid / 2**maximum_level\n",
      "print \"Spatial resolution is %s\" % dx.in_units('pc')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "disk_mass = 42.9661e9*Msun\n",
      "gas_mass = 0.2*disk_mass\n",
      "radial_scale_length = 3.4218*kpc\n",
      "vertical_scale_length = 0.34218*kpc "
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "initial_temperature = 1e4*Kelvin\n",
      "mu = 1.4*mp\n",
      "gamma = 5./3.\n",
      "cs = sqrt(gamma*kb*initial_temperature/mu).in_units('km/s')\n",
      "print \"Initial sound speed is %s\" % cs"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "jeans_number = 4  # Number of cells to resolve jeans length by\n",
      "jeans_density = ((1.0/(jeans_number*dx))**2*(pi*cs**2)/G).in_units('g/cm**3')\n",
      "jeans_length = sqrt(pi*gamma*kb*initial_temperature/G/mu/jeans_density).in_units('pc')\n",
      "jeans_mass = (4./3.*pi*(jeans_length/2)**3*jeans_density).in_units('Msun')\n",
      "\n",
      "print \"Jeans number density at resolution limit is %s\" % (jeans_density/mp)\n",
      "print \"Jeans mass at resolution limit is %s\" % jeans_mass\n",
      "print \"Jeans length at resolution limit is %s\" % jeans_length"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "mass_units = 1e9*Msun\n",
      "length_units = box_size\n",
      "time_units = Gyr"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "In your parameter file, you should set parameters using the following values:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print \"AgoraRestartScaleLength     = %g\" % (radial_scale_length/box_size).in_units('')\n",
      "print \"AgoraRestartScaleHeight     = %g\" % (vertical_scale_length/box_size).in_units('')\n",
      "print \"AgoraRestartDiskMass        = %g\" % (disk_mass/1e9*Msun)\n",
      "print \"AgoraRestartGasFraction     = %g\" % (gas_mass/disk_mass)\n",
      "print \"AgoraRestartDiskTemperature = %g\" % initial_temperature\n",
      "print \"\"\n",
      "print \"MassUnits   = %g\" % mass_units.in_units('g')\n",
      "print \"LengthUnits = %g\" % length_units.in_units('cm')\n",
      "print \"TimeUnits   = %g\" % time_units.in_units('s')\n",
      "print \"GravitationalConstant = %g\" % (4*pi*G*mass_units/length_units**3*time_units**2).in_units('')\n",
      "print \"\"\n",
      "print \"RefineByJeansLengthSafetyFactor = %i\" % jeans_number"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Note that this parameter listing is not exhaustive and only reflects the parameters that change with varying resolution or that depend on the model galaxy properties."
     ]
    }
   ],
   "metadata": {}
  }
 ]
}